import { createSlice } from "@reduxjs/toolkit";

// 初始化的数据
const initialState = {
  username: "张三",
};

// 创建Slice
const userSlice = createSlice({
  name:"user",
  initialState,
  reducers:{
    setUserInfo(state,{payload}){
      // console.log(action)
      state.username = payload
    }
  }
})

// 导出action
export const { setUserInfo } = userSlice.actions
// 导出reducer
export default userSlice.reducer
